package com.truthbean.jeetb.utils.web;

import java.io.*;

public class StreamConnector extends Thread {
    private InputStream is;
    private OutputStream os;

    public StreamConnector(InputStream is, OutputStream os) {
        this.is = is;
        this.os = os;
    }

    public void run() {
        BufferedReader in = null;
        BufferedWriter out = null;
        try {
            in = new BufferedReader(new InputStreamReader(this.is));
            out = new BufferedWriter(new OutputStreamWriter(this.os));
            char buffer[] = new char[8192];
            int length;
            while ((length = in.read(buffer, 0, buffer.length)) > 0) {
                out.write(buffer, 0, length);
                out.flush();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            if (in != null)
                in.close();
            if (out != null)
                out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}